<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type='text/javascript' src='<?php echo $data['baseurl']; ?>global/js/jquery-1.7.min.js'></script>
<style type="text/css">
.personal-button{
border : 1px solid #2DACBF;
cursor : pointer;
padding : 5px;
}

.personal-button:hover{
background-color: white;  
}

.personnal-border{
border : 1px solid #2DACBF;  
}

#component-add-image-form input[type=submit]{
display : block;
margin-top : 10px;
margin-left : auto;
margin-right: auto;
}

#component-add-image-form input[type=file]{
display : block;
margin-top : 10px;
margin-left : auto;
margin-right: auto;
}

#component-add-image-preview{
padding : 5px;
border : 1px solid black;
text-align: center;
min-width : 100px;
min-height : 100px;
margin-left : auto;
margin-right: auto;
margin-top : 30px;
background-color: white;
}

#component-add-image-preview img{
height : 100px;
}

#display-error{
padding : 5px;
background-color: green;
color : white;
text-align: left;
border : 1px dotted white;
font-size : 11px;
}

</style>
</head>

<body>

<div id='display-error'>Formats de fichier autorisés : .jpg et .jpeg</div>

<form method="post" action="<?php echo $data['baseurl']; ?>syndication_up" id='component-add-image-form' enctype="multipart/form-data" onsubmit="return submitFormUpload();">
  <input type='file' name='profile_pic' class='personnal-border' id='profile_pic'>
  <input type='submit' value='Ajouter' class='personal-button'>
  <input type='hidden' name='action-upload' value='true'>
  <input type='hidden' name='cha_id' value='<?php echo $data['cha_id']; ?>'>
</form>

<div id='component-add-image-preview'>
      <img src='<?php echo $data['baseurl']; ?>global/img/appartements/pictures/thumbnails/<?php echo $data['pic']; ?>' alt='Aperçu'>
</div>

<script type="text/javascript">
if("<?php echo $data['error']; ?>" != ""){
  $("#display-error").html("<?php echo $data['error']; ?>");
  $("#display-error").css({'backgroundColor':'red', 'display': 'block'});
}

function submitFormUpload(){
  if($("#profile_pic").val() == ""){
    alert("\t\t\t\tAïe !!\nIl faut sélectionner une photo avant de valider ;)");
    return false;
  }
  $("#component-add-image-preview").css("background", "white url('<?php echo $data['baseurl']; ?>global/img/globalbo/appartements/ajax-loader.gif') center no-repeat");
  return true;  
}
</script>
